package webshop.beans;

import java.util.Iterator;
import java.util.List;

import database.entity.ItemGroup;
import database.entity.ShopItem;
import database.entitymanager.ItemGroupManager;
import database.entitymanager.ShopItemManager;

public class MainMenuBean{
	
	private List<ItemGroup> itemGroups=null;
	private static final int SHOP_ITEM_DISPLAY_COUNT = 9;
	private List<ShopItem> shopItems = null;
	
	public MainMenuBean(){	
	}
	
	public List<ItemGroup> getMenuItems(){
		if(itemGroups==null){
			itemGroups=ItemGroupManager.findItemGroupEntities();
			Iterator it=itemGroups.iterator();
			while(it.hasNext()){
				ItemGroup g=(ItemGroup)it.next();
				if(g.getItemgrouplevel()>0){
					it.remove();
				}
			}
		}		
		return itemGroups;		
	}
	
	public List<ShopItem> getShopItems(){
		if(shopItems==null){
			shopItems=ShopItemManager.findShopItemEntities(SHOP_ITEM_DISPLAY_COUNT,0);
		}
		return shopItems;
	}
	
			
}